﻿using UnityEngine;
using ZCUIManager;

namespace ZCMain
{
    public class MainSelectView : UIBaseView
    {
        #region
        private GameObject m_SelectGo;
        #endregion

        #region
        public override bool isUIView => false;

        public override bool isSingleton => true;

        public GameObject SelectGo
        {
            get
            {
                return m_SelectGo;
            }
            set
            {
                bool switchSuccess;
                bool isShow;
                SelectAttribute attribute = value.GetComponent<SelectAttribute>();
                switch (attribute.SelectType)
                {
                    case eSelectType.Main:
                        switchSuccess = MainController.Instance.SwitchView(eUIType.MainView);
                        isShow = false;
                        break;
                    case eSelectType.Paper:
                        switchSuccess = MainController.Instance.SwitchView(eUIType.TouchDrawingView);
                        isShow = true;
                        break;
                    default:
                        switchSuccess = MainController.Instance.SwitchView(eUIType.MainView);
                        isShow = false;
                        break;
                }
                if (switchSuccess)
                {
                    m_SelectGo = value;
                    SetParent(value.GetComponent<RectTransform>());
                    if (isShow)
                    {
                        Show();
                    }
                    else
                    {
                        Hide();
                    }
                }
            }
        }
        #endregion

        #region LiveTime
        public override void Initialize(eUIType uiType, GameObject go)
        {
            base.Initialize(uiType, go);
            m_GameObject.SetActive(false);
        }

        public override void SetParent(RectTransform parent)
        {
            base.SetParent(parent);
            m_RectTransform.anchoredPosition = Vector2.zero;
            m_RectTransform.sizeDelta = parent.sizeDelta;
        }
        #endregion
    }
}
